﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoodMan.Infrastructure.Entities.Repository;

namespace GoodMan.Infrastructure.Entities.Entity
{
    public class ProductRepertory : IAccessible<T_ProductRepertory, ProductRepertory>, ILogicEntity<T_ProductRepertory, ProductRepertory>
    {
        public int Id { get; set; }
        public int ProductId { get; set; }
        public int CollegeId { get; set; }
        public int DormitoryId { get; set; }
        public int Remain { get; set; }

        public Dormitory dormitory { get; set; }

        public ProductRepertory LoadDormitory(T_Dormitory dormitory)
        {
            this.dormitory = new Dormitory().Set(dormitory);
            return this;
        }

        protected override void Covariant(T_ProductRepertory model)
        {
            if (model != null)
            {
                this.CollegeId = model.CollegeId;
                this.DormitoryId = model.DormitoryId;
                this.Id = model.Id;
                this.ProductId = model.ProductId;
                this.Remain = model.Remain;
            }
        }

        protected override T_ProductRepertory Inverter(ProductRepertory model)
        {
            if (model != null)
            {
                return new T_ProductRepertory()
                {
                    CollegeId = model.CollegeId,
                    DormitoryId = model.DormitoryId,
                    Id = model.Id,
                    ProductId = model.ProductId,
                    Remain = model.Remain
                };
            }
            return null;
        }

        public ProductRepertory Set(T_ProductRepertory dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
